package flc.ast.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyFileBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class AppAdapter extends StkProviderMultiAdapter<MyFileBean> {

    public AppAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(82));
        addItemProvider(new AppProvider());
    }

    private class AppProvider extends BaseItemProvider<MyFileBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_app;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyFileBean bean) {
            if (baseViewHolder.getBindingAdapterPosition() == 0) {
                baseViewHolder.getView(R.id.line).setVisibility(View.GONE);
            }
            baseViewHolder.setImageDrawable(R.id.ivAppIcon, AppUtils.getAppIcon(bean.getPath()));
            baseViewHolder.setText(R.id.tvAppName, bean.getName());
            String phoneTime = TimeUtils.millis2String(bean.getDateModified() * 1000L, "yyyy-MM-dd HH:mm");
            baseViewHolder.setText(R.id.tvAppDate, phoneTime);
        }
    }


}
